/**
 * 
 */
package com.sesame.daoimpl;

import java.util.List;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.sesame.dao.MessageDAO;
import com.sesame.domain.Message;

/**
 * @author shubeta
 *
 */
public class MessageDAOImpl extends SqlMapClientDaoSupport implements MessageDAO {

    public void addMessage(Message message) {
        getSqlMapClientTemplate().insert("addMessage", message);
    }

    public void deleteMessageById(Integer id) {
        getSqlMapClientTemplate().delete("deleteMessageById", id);
    }
    
    public void deleteMessageByState(char state) {
        getSqlMapClientTemplate().delete("deleteMessageByState", state);
    }
    
    @SuppressWarnings("unchecked")
    public List<Message> getAllMessage() {
        return (List<Message>) getSqlMapClientTemplate().queryForList("getAllMessage");
    }

    public Message getMessageBySender(String sender) {
        return (Message) getSqlMapClientTemplate().queryForObject("getMessageBySender", sender);
    }

    public void updateMessage(Message message) {
        getSqlMapClientTemplate().update("updateMessage", message);
    }

}
